<%@page import="java.util.Arrays"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.oocl.crmweb.pojo.Customer"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Update Customer</title>
</head>
<body>
	<form action="update" method="post">
		<fieldset>
			<legend>Update</legend>
			<input type="hidden" name="id" value="${ customer.id }"/>
			<p>Name: <input type="text" name="cname" value="${ customer.cname }"/></p>
			<p>Salary: <input type="text" name="sal" value="${ customer.sal }"/></p>
			<p>
				Sex: 
				<c:if test="${ customer.sex }">
					<input type="radio" name="sex" value="true" checked="checked"/>男
					<input type="radio" name="sex" value="false"/>女
				</c:if>
				<c:if test="${ !customer.sex }">
					<input type="radio" name="sex" value="true"/>男
					<input type="radio" name="sex" value="false" checked="checked"/>女
				</c:if>
			</p>
			<p>Birth: <input type="date" name="birth" value="<% Customer c = (Customer) request.getAttribute("customer"); out.print(new SimpleDateFormat("yyyy-MM-dd").format(c.getBirth())); %>"/></p>
			<p>
				Favs: 
				<input type="checkbox" name="favs" value="basket" <% if (Arrays.binarySearch(c.getFavs(), "basket") >= 0) { out.print("checked=\"checked\""); } %>/>篮球
				<input type="checkbox" name="favs" value="football" <% if (Arrays.binarySearch(c.getFavs(), "football") >= 0) { out.print("checked=\"checked\""); } %>/>足球
			</p>
			<p><input type="submit"/></p>
		</fieldset>
	</form>
</body>
</html>